<template>
    <mi-form-page @submit="submit"
                  :loading="edit.loading"
                  v-model:show="edit.show"
                  title="登录配置"
    >
        <el-form :model="edit.info"
                 :rules="rules"
                 ref="formRef">

            <el-form-item prop="is_force_bind_mobile" label="强制绑定手机号">
                <mi-radio v-model="edit.info.value.is_force_bind_mobile" />
            </el-form-item>

            <el-form-item prop="give_coupon_id" label="注册赠送优惠券">
                <coupon-select first="top" v-model="edit.info.value.give_coupon_id" />
            </el-form-item>

            <el-form-item prop="give_points" label="注册赠送积分">
                <mi-input-number v-model="edit.info.value.give_points" />
            </el-form-item>

        </el-form>
    </mi-form-page>
</template>

<script setup lang="ts">
import {ref, onBeforeMount, inject, computed, watch} from "vue";
import {simpleGet} from "@/utils/request";
import {FormInstance} from "element-plus";
import Edit from "@/model/edit";
import CouponSelect from "@/views/store/components/CouponSelect.vue";

const url = '/site.siteConfig/edit'

const rules = {

}

const loading = ref(false)
const formRef = ref<FormInstance>()
const parentOptions = ref<any[]>([])
const edit = inject('login', new Edit({}))
edit.info = {value:{}}

const submit = () => {
    edit.submit({
        formRef: formRef.value,
        url: url,
    })
}

watch(() => edit.show, (nv,ov) => {
    edit.init(async () => {
        let {info} = await simpleGet(url, {key:'login'})
        edit.info = info
    })
})

</script>

<style scoped>

</style>

